﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using reminder_csh.Entities;

namespace reminder_csh {
    public partial class Form1 : Form {

        private WorkerManagerImpl Wmanager;
        private TaskManagerImpl Tmanager;

        public Form1() {
            InitializeComponent();
            Wmanager=new WorkerManagerImpl();
            Tmanager=new TaskManagerImpl();
        }

        private void workerToolStripMenuItem_Click(object sender, EventArgs e) {
            var workerCreateForm=new Form2();
            workerCreateForm.ShowDialog();
        }

        private void taskToolStripMenuItem_Click(object sender, EventArgs e) {
            var taskCreateForm=new Form3();
            taskCreateForm.ShowDialog();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e) {
            var about=new AboutBox1();
            about.ShowDialog();
        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e) {
            this.Close();
        }

        private void button5_Click(object sender, EventArgs e) {
            var choosePicture=new Form4();
            choosePicture.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var f4 = new Form4 {worker = (Worker) nameComboBox.SelectedItem};

            f4.ShowDialog();

        }

        private void button2_Click(object sender, EventArgs e) {
            var taskCreateForm=new Form3();
            taskCreateForm.ShowDialog();
        }

        

        private void Form1_Load(object sender, EventArgs e)
        {
            
            nameComboBox.Items.AddRange(Wmanager.FindAllPersons().ToArray());

        }

        private void nameComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var nameInBox = nameComboBox.Text;
            var worker = (Worker) nameComboBox.SelectedItem;
            var id = worker.Id;
            Wmanager.FindPersonById(id);

          //  tasksDataGridView.DataSource(worker.Tasks);

        }


    }
}
